class CinemasController < ApplicationController
  before_filter :authorize, :only => [:new, :edit, :create, :update, :destroy, :admin_index]
  
  layout 'admin_layout'
  
  def site_index
  end
  
  def admin_index
  end
  
  def index
    @cinemas = Cinema.find(:all)
  end
  
  def show
    @cinema = Cinema.find(params[:id])
  end
  
  def new
    @cinema = Cinema.new
  end
  
  def edit
    @cinema = Cinema.find(params[:id])
  end
  
  def create
    @cinema = Cinema.new(params[:cinema])
    if @cinema.save
      flash[:notice] = "The cinema information saved successfully!"
      redirect_to :action => 'index'
    else
      render :action => 'new'
    end
  end
  
  def update
    @cinema = Cinema.find(params[:id])
    if @cinema.update_attributes(params[:cinema])
      flash[:notice] = "The cinema information updated successfully!"
      redirect_to :action => 'index'
    else
      redirect_to :back
    end
  end
  
  def destroy
    @cinema = Cinema.find(params[:id])
    @cinema.destroy
    flash[:notice] = "The cinemainformation destroied successfully!"
    redirect_to :action => 'index'
  end
end
